//
// Created by 67678 on 2023/3/17.
//

#ifndef WEBSERVER_DATEBASE_H
#define WEBSERVER_DATEBASE_H

#include <string>
#include <mutex>
#include "hiredis.h"
#include "../util/nonCopyable.h"

namespace dateBase {
class DateBase : util::NonCopyable {
public:
    static DateBase &getInstance() {
        static DateBase db;
        return db;
    }

    std::string set(std::string_view key, std::string_view value);

    std::string get(std::string_view key);

private:
    DateBase();

    ~DateBase();

    redisContext *conn_ = nullptr;
    std::mutex mx_;
};
}
#endif //WEBSERVER_DATEBASE_H
